package com.mzpai.web.controller;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.mzpai.product.model.MsgLog;
import com.mzpai.product.service.MsgLogService;
import com.mzpai.vo.ResponseCode;
import com.mzpai.vo.ResponseVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 查询消息
 * @author yanglijun
 */

@Api(value = "查询消息接口")
@RestController
@RequestMapping("/msgLog")
public class MsgLogController {
	
	private static Logger log = LoggerFactory.getLogger(LoginController.class);
	@Autowired 
	private MsgLogService msgLogService;
	
	/** 
	*
	* 查询列表 
	* @throws Exception
	*/
	@ApiOperation(value = "查询消息，根据用户id查询,显示最近50条记录")
	@RequestMapping(value = "/queryByUserAdminId")
	@ResponseBody
	public ResponseVo<List<MsgLog>> queryByUserAdminId(@RequestParam(value = "adminId", required = true) String adminId) throws Exception {
		ResponseVo<List<MsgLog>> res=new ResponseVo<List<MsgLog>>();
		try{
			log.info("msg1=传入adminId信息={}", adminId);
			if(StringUtils.isNotBlank(adminId)) {
				List<MsgLog> list = msgLogService.queryByAdminId(adminId);
				res.setResult(list);
			}
		} catch(Exception e) {
			log.error("msg1=根据订单查询异常，{}",e );
			res.fail(ResponseCode.FAILURE.getCode(), "获取消息信息失败.");
		}
		return res;
	}

}
